/**   
 * Copyright © 2016 公司名. All rights reserved.
 * 
 * @Title: UserLoginLogServiceImpl.java 
 * @Prject: LianniuWeb
 * @Package: com.lianniu.web.baseService.user.service.impl
 * @Description: TODO
 * @author: lzz   
 * @date: 2016年8月4日 上午11:11:14 
 * @version: V1.0   
 */
package com.lianniu.web.baseService.user.service.impl;


import java.util.Date;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.lianniu.web.base.BaseResult;
import com.lianniu.web.baseService.user.dao.IUserLoginLogDao;
import com.lianniu.web.baseService.user.model.UserLoginLogVo;
import com.lianniu.web.baseService.user.service.IUserLoginLogService;
import com.lianniu.web.constants.ErrorCode;
import com.lianniu.web.util.StringUtil;

/** 
 * @ClassName: UserLoginLogServiceImpl 
 * @Description: TODO
 * @author: lzz
 * @date: 2016年8月4日 上午11:11:14  
 */
@Service("userLoginLogService")
public class UserLoginLogServiceImpl implements IUserLoginLogService{

    @Resource
    private IUserLoginLogDao userLoginLogDao;
    private final static Logger logger = Logger.getLogger(UserLoginLogServiceImpl.class);
    @Override
    public BaseResult addUserLoginLog(UserLoginLogVo userLoginLogVo) {
        logger.info("addUserLoginLog begin.");
        logger.info("userLoginLogVo:"+ JSON.toJSONString(userLoginLogVo));
        BaseResult baseResult;
        logger.info("addUserLoginLog addUserLoginLog begin.");
        int i = userLoginLogDao.addUserLoginLog(userLoginLogVo);
        baseResult = BaseResult.success(i);
        logger.info("addUserLoginLog addUserLoginLog end.");
        logger.info("addUserLoginLog end.");
        return baseResult;
    }
    @Override
    public BaseResult writeLoginOutTime(long logId){
        logger.info("writeLoginOutTime begin.");
        UserLoginLogVo userLoginLogVo = new UserLoginLogVo();
        userLoginLogVo.setId(logId);
        userLoginLogVo.setLogOutTime(new Date());
        logger.info("writeLoginOutTime updateOutTime begin.");
        int i = userLoginLogDao.updateOutTime(userLoginLogVo);
        logger.info("writeLoginOutTime updateOutTime end.");
        logger.info("writeLoginOutTime end.");
        return BaseResult.success(i);
    }
}